
	** Append Tanzania waves
	
		use "$dir/data/tza_w1_individual.dta", clear
		ren w1_* *
		gen wave="w1"
		tempfile data
		save `data', replace
		
		qui foreach wave in w2 w3 w4 w5 {
			use "$dir/data/tza_`wave'_individual.dta", clear
			ren `wave'_* *
			gen wave="`wave'"
			append using `data'
			save `data', replace
		}
			
	** Age groups
	
		replace age=. if age<0
		gen age_group5=floor(age/5)*5
		gen age_group10=floor(age/10)*10
		
		replace age_group5=80 if age_group5>80 & !missing(age_group5)
		replace age_group10=80 if age_group10>80 & !missing(age_group10)
		
	** Any work
	
		egen work_any=rowmax(work_outsideHH work_agHH work_bizHH)
	
	** Lives alone
	
		gen lives_alone=(hh_size==1)
	
	** Disability

		gen disability=(																	 	 ///
			diff_seei==1 | 																	 	 ///
			diff_hear==1 | 																	     ///
			diff_walk_clim==1 | 															     ///
			diff_reme==1 | 																	     ///
			diff_self_care==1 |																	 ///
			diff_comm==1																		 ///
			)
		replace disability=. if (														         ///
			missing(diff_seei) &																 ///
			missing(diff_hear) & 														     	 ///
			missing(diff_walk_clim) & 														 	 ///
			missing(diff_reme) &																 ///
			missing(diff_self_care) &														     ///
			missing(diff_comm)       															 ///
			)
	
	** Indentifiers
		set seed 1234
		ren indiv indiv_w1
		sort hhid_w5 hhid_w4 hhid_w3 hhid_w2 hhid_w1 indiv_w5 indiv_w4 indiv_w3 indiv_w2 indiv_w1
		gen hhid=hhid_w5 if wave=="w5"
		replace hhid=hhid_w4 if wave=="w4"
		replace hhid=hhid_w3 if wave=="w3"
		replace hhid=hhid_w2 if wave=="w2"
		replace hhid=hhid_w1 if wave=="w1"
		
		*egen hhid=group(hhid_w5 hhid_w4 hhid_w3 hhid_w2 hhid_w1)
		egen indiv=group(indiv_w5 indiv_w4 indiv_w3 indiv_w2 indiv_w1)
		
	** Save
		
		save "$dir/data/tza.dta", replace
